import pandas as pd
import numpy as np

# 加载数据
file_path = r"C:\Users\18344\Desktop\中文ACDEF题\中文赛题ACDEF题\E题\results\bearing_features.csv"
data = pd.read_csv(file_path)

# 筛选出数值型列，去除非数值列（如文件名、轴承类型等）
numeric_data = data.select_dtypes(include=[np.number])

# 计算基础统计特征
mean_values = numeric_data.mean()
std_values = numeric_data.std()
var_values = numeric_data.var()
rms_values = np.sqrt(np.mean(numeric_data**2))
max_values = numeric_data.max()
min_values = numeric_data.min()
peak_to_peak_values = max_values - min_values
abs_mean_values = numeric_data.abs().mean()

# 包含一些偏度和峰度等特征
skewness = numeric_data.skew()
kurtosis = numeric_data.kurt()

# 创建报告
report = pd.DataFrame({
    'Mean': mean_values,
    'Std': std_values,
    'Variance': var_values,
    'RMS': rms_values,
    'Max': max_values,
    'Min': min_values,
    'Peak-to-Peak': peak_to_peak_values,
    'Abs Mean': abs_mean_values,
    'Skewness': skewness,
    'Kurtosis': kurtosis
})

# 保存报告到CSV文件
report.to_csv("bearing_feature_report.csv")

# 显示报告
print("报告已生成：bearing_feature_report.csv")
print(report.head())  # 输出前几行
